<template>
  <div class="main">
      <el-container>
      <el-aside :style="isCollapse? 'width:' +'60'+ 'px':  'width:' +'200'+ 'px' ">
        <leftNav :isCollapse="isCollapse" :mockJSON="Menu"/>
      </el-aside>
      <el-container>
        <el-header>
          <Header :isCollapse="isCollapse" @isCollapseClick="handelZiCompont($event)"></Header>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer>
          <Footer></Footer>
        </el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import mockJSON from '@/mock/MenuConfig'
import leftNav from '@/components/LeftNav'
import Header from '@/components/Header'
import Footer from '@/components/Footer'
import memoryUtils from '@/utils/memoryUtils'
export default {
  name: 'Main',
  data () {
    return {
      isCollapse: false,
      Menu: mockJSON
    };
  },
  components: {
    leftNav,
    Header,
    Footer
  },
  created () {
    const user = memoryUtils.user;
    if (!user || !user.id) this.$router.push('/login')
  },
  mounted () {
  },
  methods: {
    handelZiCompont (msg) {
      this.isCollapse = msg;
    }
  }
}
</script>

<style scoped>
.main {
  height: 100%;
}
.el-header, .el-footer {
  background-color: #B3C0D1;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 160px;
}
.el-aside {
  background-color: #545c64;
}
.el-container {
  height: 100%;
  margin-bottom: 40px;
}
.header-left {
  cursor: pointer;
}
</style>
